import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '供应商编号',
    align:"center",
    dataIndex: 'supplierId'
   },
   {
    title: '供应商名称',
    align:"center",
    dataIndex: 'supplierName'
   },
   {
    title: '供应商联系人',
    align:"center",
    dataIndex: 'contactName'
   },
   {
    title: '供应商邮箱',
    align:"center",
    dataIndex: 'email'
   },
   {
    title: '供应商电话',
    align:"center",
    dataIndex: 'phoneNumber'
   },
   {
    title: '供应商地址',
    align:"center",
    dataIndex: 'address'
   },
   {
    title: '供应商邮政编码',
    align:"center",
    dataIndex: 'postalCode'
   },
   {
    title: '供应商所在的国家',
    align:"center",
    dataIndex: 'country'
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '创建时间',
    align:"center",
    sorter: true,
    dataIndex: 'createTime'
   },
   {
    title: '修改人',
    align:"center",
    dataIndex: 'updateBy'
   },
   {
    title: '修改时间',
    align:"center",
    sorter: true,
    dataIndex: 'updateTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "供应商编号",
      field: 'supplierId',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "供应商名称",
      field: 'supplierName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "供应商联系人",
      field: 'contactName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "供应商邮箱",
      field: 'email',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "供应商电话",
      field: 'phoneNumber',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "供应商地址",
      field: 'address',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "供应商邮政编码",
      field: 'postalCode',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "供应商所在的国家",
      field: 'country',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "创建人",
      field: 'createBy',
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "创建时间",
      field: "createTime",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
          showTime:true
      },
      //colProps: {span: 6},
	},
	{
      label: "修改人",
      field: 'updateBy',
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "修改时间",
      field: "updateTime",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
          showTime:true
      },
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '供应商编号',
    field: 'supplierId',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商编号!'},
          ];
     },
  },
  {
    label: '供应商名称',
    field: 'supplierName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商名称!'},
          ];
     },
  },
  {
    label: '供应商联系人',
    field: 'contactName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商联系人!'},
          ];
     },
  },
  {
    label: '供应商邮箱',
    field: 'email',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商邮箱!'},
                 { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'},
          ];
     },
  },
  {
    label: '供应商电话',
    field: 'phoneNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商电话!'},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '供应商地址',
    field: 'address',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商地址!'},
          ];
     },
  },
  {
    label: '供应商邮政编码',
    field: 'postalCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商邮政编码!'},
                 { pattern: /^[0-9]\d{5}$/, message: '请输入正确的邮政编码!'},
          ];
     },
  },
  {
    label: '供应商所在的国家',
    field: 'country',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入供应商所在的国家!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  supplierId: {title: '供应商编号',order: 0,view: 'number', type: 'number',},
  supplierName: {title: '供应商名称',order: 1,view: 'text', type: 'string',},
  contactName: {title: '供应商联系人',order: 2,view: 'text', type: 'string',},
  email: {title: '供应商邮箱',order: 3,view: 'text', type: 'string',},
  phoneNumber: {title: '供应商电话',order: 4,view: 'text', type: 'string',},
  address: {title: '供应商地址',order: 5,view: 'text', type: 'string',},
  postalCode: {title: '供应商邮政编码',order: 6,view: 'text', type: 'string',},
  country: {title: '供应商所在的国家',order: 7,view: 'text', type: 'string',},
  createBy: {title: '创建人',order: 8,view: 'text', type: 'string',},
  createTime: {title: '创建时间',order: 9,view: 'datetime', type: 'string',},
  updateBy: {title: '修改人',order: 10,view: 'text', type: 'string',},
  updateTime: {title: '修改时间',order: 11,view: 'datetime', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
